package com.example.kafka.controller;

import com.example.kafka.service.BatchOffsetCommitService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 演示整批次最后位点提交的错误示例
 */
@RestController
@RequestMapping("/api/v1/batch-offset-commit")
@RequiredArgsConstructor
public class BatchOffsetCommitController {

    private final BatchOffsetCommitService service;

    /**
     * 用例1: 批量订单处理 - 整批次最后位点提交
     */
    @PostMapping("/batch-order")
    public String processBatchOrders(@RequestBody String ordersData) {
        return service.processBatchOrders(ordersData);
    }

    /**
     * 用例2: 批量支付处理 - 整批次最后位点提交
     */
    @PostMapping("/batch-payment")
    public String processBatchPayments(@RequestBody String paymentsData) {
        return service.processBatchPayments(paymentsData);
    }

    /**
     * 用例3: 批量库存更新 - 整批次最后位点提交
     */
    @PostMapping("/batch-inventory")
    public String updateBatchInventory(@RequestBody String inventoryData) {
        return service.updateBatchInventory(inventoryData);
    }

    /**
     * 用例4: 批量用户注册 - 整批次最后位点提交
     */
    @PostMapping("/batch-user-registration")
    public String processBatchUserRegistrations(@RequestBody String usersData) {
        return service.processBatchUserRegistrations(usersData);
    }

    /**
     * 用例5: 批量日志处理 - 整批次最后位点提交
     */
    @PostMapping("/batch-log")
    public String processBatchLogs(@RequestBody String logsData) {
        return service.processBatchLogs(logsData);
    }
}
